<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>search_n</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">C++ Algorithms</a> &gt; <a href=
    "search_n.html">search_n</a>
  </div>

  <div class="name-format">
    search_n
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;algorithm&gt;
  iterator search_n( iterator start, iterator end, size_t num, const <a href="../containers.html">TYPE</a>&amp; val );
  iterator search_n( iterator start, iterator end, size_t num, const <a href="../containers.html">TYPE</a>&amp; val, BinPred p );
</pre>

  <p>The search_n() function looks for <em>num</em> occurances of
  <em>val</em> in the range [<em>start</em>,<em>end</em>).</p>

  <p>If <em>num</em> consecutive copies of <em>val</em> are found,
  search_n() returns an iterator to the beginning of that sequence.
  Otherwise it returns an iterator to <em>end</em>.</p>

  <p>If the optional binary predicate <em>p</em> is given, then it is
  used to perform comparisons between elements.</p>

  <p>This function runs in <a href="../complexity.html">linear
  time</a>.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    <a href="find_end.html">find_end</a><br>
    <a href="find_if.html">find_if</a><br>
    <a href="search.html">search</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
